package com.datang.pet.api.ossController;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-05-14 23:37
 * @notify
 * @version 1.0
 */

import com.datang.pet.common.ossUtils.WebSign;
import com.datang.pet.common.response.Result;
import com.datang.pet.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class GetOssPolicyController {
    @Autowired
    private  UserService userService;
    /*
     * @author 顶风少年
     * @date 2019/5/29 14:07
     * @mail dfsn199703132038@foxmail.com
     * @throws
     * @param
     * @param type 1图片2视频3bgm
     * @param id
     * @result Result
     * @notify
     * version 1.0
     */
    @GetMapping("/getUploadFileOssPolicy")
    public Result getOssPolicy(Integer type, String userId) throws Exception {
            boolean b = userService.userIsExist(userId);
            if (b) {
                Map<String, String> resultMap = WebSign.getOssPolicy(type);
                return Result.ok("成功", resultMap);
            } else {
                return Result.err("用户不存在");
            }
    }
}
